package com.example.beryl.http;

import com.example.beryl.Util.Android_log;
import com.example.beryl.entity.Action;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 完工报工网络连接类
 */
public class Net_finishWork {
    private ArrayList<String> arrayList = new ArrayList<String>();
    private ArrayList<String> brrayList = new ArrayList<String>();
    private ArrayList<String> crrayList = new ArrayList<String>();
    private Net_method soap2 = new Net_method();
    //private static String URL ="finishWorks.asmx";//服务器地址
    private static String URL ="FinishWork.asmx";//调试地址

    public List<String> CS_CommonMethod(String what, String para)
    {

        List<String> list = new ArrayList<>();
        try
        {
            switch (what)
            {
                case Action.action.finishWareHouseCode://仓库和库位
                    list = getWareHouseCode(para);
                    break;
                case Action.action.finishWorkBarcode://获取流传单信息
                    list = getBarCode(para);
                    break;
                case Action.action.finishCheckSummitData:
                    list = checkSummitData(para);
                    break;
                case Action.action.finishSummitData:
                    list = SummitData(para);
                    break;
            }

        }catch (Exception e)
        {

        }
        return list;
    }

    public List<String> getWareHouseCode(String para) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(para);
        try
        {
            crrayList = soap2.SummitData("getWareHouseCode", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    public List<String> getBarCode(String barcode) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("barcode");
        brrayList.add(barcode);
        try
        {
            crrayList = soap2.SummitData("selectBarCode", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    public List<String> checkSummitData(String para) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(para);
        try
        {
            crrayList = soap2.SummitData("checkSummitData", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    public List<String> SummitData(String para) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(para);
        try
        {
            crrayList = soap2.SummitData("SummitData", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }
}
